﻿using System;
using System.Data;
using System.Collections;
using CE.Database;

/// <summary>
/// Summary description for FleetTransactionDB
/// </summary>
namespace CE.CarInsurance
{
    public class FleetTransactionDB
    {
        public Int64 Insert(FleetTransaction fleettransaction)
        {
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            Int64 _result = -1;
            string _spName = "sprocCXCRMFleetTransactionInsertUpdateSingleItem";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@AgentId", fleettransaction.AgentId);
            _sPara.Add("@AdminId", fleettransaction.AdminId);
            _sPara.Add("@RefCEUserId", fleettransaction.RefCEUserId);
            _sPara.Add("@FleetCarId", fleettransaction.FleetCarId);
            _sPara.Add("@CompanyId", fleettransaction.CompanyId);
            _sPara.Add("@ProviderCompanyId", fleettransaction.ProviderCompanyId);
            _sPara.Add("@QuoteRefNo", fleettransaction.QuoteRefNo);
            _sPara.Add("@TransactionTypeId", fleettransaction.TransactionTypeId);
            _sPara.Add("@Remarks", fleettransaction.Remarks);
            _sPara.Add("@Status", fleettransaction.Status);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public DataSet GetTransaction(string QuoteRefNo, Int16 TransactionTypeId)
        {
            DataSet _dsTransaction = null;
            MyDatabase _db = new MyDatabase("GG_CRMDBConnectionString");
            string _spName = "sprocCXCRMFleetTransactionSelectItemByQuoteRefNo";

            SortedList _spara = new SortedList();
            _spara.Add("@QuoteRefNo", QuoteRefNo);
            _spara.Add("@TransactionTypeId", TransactionTypeId);

            using (DataSet _ds = _db.GetDataSet(_spName, _spara))
            {
                if (_ds != null && _ds.Tables.Count > 0 && _ds.Tables[0].Rows.Count > 0)
                {
                    _dsTransaction = _ds;
                }
            }
            return _dsTransaction;
        }

    }
}